/*
 * @Author: Wangjun
 * @Date: 2021-06-04 22:33:21
 * @LastEditTime: 2021-06-07 09:30:18
 * @LastEditors: Wangjun
 * @Description:
 * @FilePath: \lua\luaquery\init.go
 * hnxr
 */
package luaquery

import (
	lua "github.com/yuin/gopher-lua"
)

//InitLuaDB 注册默认函数
func InitLuaDB(l *lua.LState) {
	mt := l.NewTypeMetatable(luaQuery)
	l.SetGlobal(luaQuery, mt)
	l.SetField(mt, "new", l.NewFunction(newQuery))
	l.SetField(mt, "__index", l.SetFuncs(l.NewTable(), map[string]lua.LGFunction{
		"EQ":  eq,
		"Avg": avg,
		"Sum": sum,
		"Min": min,
		"Max": max,
	}))

}
